﻿using System.Collections.Generic;
using NLog;
using System;

namespace ArtheaEngine
{
    public partial class Room : IFormattable
    {
        private static readonly Logger log = LogManager.GetCurrentClassLogger();

        public ICollection<Character> Characters { get; private set; }

        public ICollection<Object> Objects { get; private set; }

        partial void OnCreated()
        {
            Characters = new LinkedList<Character>();
            Objects = new LinkedList<Object>();
        }

        public bool Equals(Room obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj._RoomID == _RoomID;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Room)) return false;
            return Equals((Room) obj);
        }

        public override int GetHashCode()
        {
            return _RoomID.GetHashCode();
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            if (string.IsNullOrEmpty(format)) format = "G";
            
            switch(format.ToUpper())
            {
                case "G":
                case "N":
                    return Name.ToString(formatProvider);
                case "D":
                    return Description.ToString(formatProvider);
                default:
                    throw new FormatException("invalid room format");
            }
        }
    }

    public enum RoomType
    {
        Inside,
        City,
        Field,
        Forest,
        Hills,
        Mountain,
        Water,
        Air,
        Desert,
        Jungle,
        Road,
        Path,
        Cave,
        Swamp
    }
}